using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableFieldBossDao:DaoBase<TableFieldBoss>
    {
        public override void AddPrimaryIndex(TableFieldBoss model)
        {
            cachePrimary[model.Id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableFieldBoss.txt";
        }

        protected override TableFieldBoss ParseRowData(string[] rowData)
        {
            TableFieldBoss data = new TableFieldBoss();

            if (string.IsNullOrEmpty(rowData[0]))
            {
                data.Id = 0;
            }
            else
            {
                data.Id = int.Parse(rowData[0]);
            }
			data.BossId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.BornAngle = 0;
            }
            else
            {
                data.BornAngle = double.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.RebornTime = 0;
            }
            else
            {
                data.RebornTime = long.Parse(rowData[3]);
            }
			data.RebornEffect = rowData [4];
			data.DeathEffect = rowData [5];
			data.BattleEffect = rowData [6];
			data.rewardGroupId = rowData [7];
			data.KillReward = rowData [8];

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.TeamLeader = 0;
            }
            else
            {
                data.TeamLeader = int.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.GroupIndex = 0;
            }
            else
            {
                data.GroupIndex = int.Parse(rowData[10]);
            }
			data.HeroId = rowData [11];

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.Level = 0;
            }
            else
            {
                data.Level = int.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.Attack = 0;
            }
            else
            {
                data.Attack = int.Parse(rowData[13]);
            }

            if (string.IsNullOrEmpty(rowData[14]))
            {
                data.PhyDefend = 0;
            }
            else
            {
                data.PhyDefend = int.Parse(rowData[14]);
            }

            if (string.IsNullOrEmpty(rowData[15]))
            {
                data.MagicDefend = 0;
            }
            else
            {
                data.MagicDefend = int.Parse(rowData[15]);
            }

            if (string.IsNullOrEmpty(rowData[16]))
            {
                data.Hp = 0;
            }
            else
            {
                data.Hp = int.Parse(rowData[16]);
            }

            if (string.IsNullOrEmpty(rowData[17]))
            {
                data.hit = 0;
            }
            else
            {
                data.hit = double.Parse(rowData[17]);
            }

            if (string.IsNullOrEmpty(rowData[18]))
            {
                data.dodge = 0;
            }
            else
            {
                data.dodge = double.Parse(rowData[18]);
            }

            if (string.IsNullOrEmpty(rowData[19]))
            {
                data.cri = 0;
            }
            else
            {
                data.cri = double.Parse(rowData[19]);
            }

            if (string.IsNullOrEmpty(rowData[20]))
            {
                data.antiCri = 0;
            }
            else
            {
                data.antiCri = double.Parse(rowData[20]);
            }

            if (string.IsNullOrEmpty(rowData[21]))
            {
                data.criFactor = 0;
            }
            else
            {
                data.criFactor = double.Parse(rowData[21]);
            }

            if (string.IsNullOrEmpty(rowData[22]))
            {
                data.damageAdd = 0;
            }
            else
            {
                data.damageAdd = double.Parse(rowData[22]);
            }

            if (string.IsNullOrEmpty(rowData[23]))
            {
                data.damageReduce = 0;
            }
            else
            {
                data.damageReduce = double.Parse(rowData[23]);
            }
			data.SkillId1 = rowData [24];
			data.SkillId2 = rowData [25];
			data.UltSkillId = rowData [26];

            if (string.IsNullOrEmpty(rowData[27]))
            {
                data.SkillCastChance = 0;
            }
            else
            {
                data.SkillCastChance = double.Parse(rowData[27]);
            }
			data.Talent0 = rowData [28];
			data.Talent1 = rowData [29];
			data.Talent2 = rowData [30];
			data.Talent3 = rowData [31];
			data.Talent4 = rowData [32];
			data.Talent5 = rowData [33];

            if (string.IsNullOrEmpty(rowData[34]))
            {
                data.Location = 0;
            }
            else
            {
                data.Location = int.Parse(rowData[34]);
            }

            if (string.IsNullOrEmpty(rowData[35]))
            {
                data.bloodNumber = 0;
            }
            else
            {
                data.bloodNumber = int.Parse(rowData[35]);
            }

            return data;
        }



        public override void AddTwoIndex(TableFieldBoss model)
        {
            string key = GetUnionKey(model.BossId.ToString(),model.GroupIndex.ToString());
            if (!cacheTwoIndex.ContainsKey(key))
            {
                cacheTwoIndex[key] = new List<TableFieldBoss>();
            }
            cacheTwoIndex[key].Add(model);
        }


    }

}
